/**
 * Created by caiqi on 17/4/22.
 */
import Vue from 'vue';
import VueRouter from 'vue-router';
//相关
const pageView = (resolve) => {
	require.ensure([], () => {
		resolve(require('@/views/pageView.vue'))
	})
}

//相关
const document = (resolve) => {
	require.ensure([], () => {
		resolve(require('@/views/document/index.vue'))
	})
}

//相关
const documentD = (resolve) => {
	require.ensure([], () => {
		resolve(require('@/views/document/detail.vue'))
	})
}

Vue.use(VueRouter);
const router = new VueRouter({
	mode: 'history',
	routes: [
		{ path: '*', redirect: '/' },
		{
			path: '/',
			name: 'home',
			component: pageView,
			meta: {
				title: "helper"
			},
			children: [
				{
					path: '/',
					name: 'document',
					component: document,
					meta: {
						title: "Helper"
					}
				},
				{
					path: '/docDetail/:id',
					name: 'docDetail',
					component: documentD,
					meta: {
						title: "文档详情"
					}
				},
			]
		},
	]
});
router.beforeEach((to, from, next) => {
	// window.document.title = to.meta.title
	next()
});

export default router; //将路由器导出